const Controller = require('../../core/controller/ApiController');
const { Route, HttpGet, Middleware, filters } = require('../../../plugin/egg-decorator-router/lib');
const { ExceptionHandler } = require('../../../plugin/egg-controller-exception-handler/lib');

//服务端获取老人信息
@Route('/api/mobile/aged')
class AgedController extends Controller {

    @HttpGet('/list')
    @ExceptionHandler()
    async getAgedList(){
        const rule = {
            pn: 'int',
            ps: 'int',
            kw: {type: 'string', allowEmpty: true}
        };
        this.validate(rule, this.ctx.request.query);
        this.result.data = await this.service.mobile.aged.main.getAgedList(this.ctx.request.query);
        return '查询成功'  //返回prompt，可选，一般不需要
    }

    @HttpGet('/:id')
    @ExceptionHandler()
    async getAgedInfo(){
        const rule = {
            id: 'int'
        };
        this.validate(rule, this.ctx.params);
        this.result.data = await this.service.mobile.aged.main.getAgedInfo(this.ctx.params.id);
        return '查询成功'  //返回prompt，可选，一般不需要
    }

}

module.exports = AgedController;



